#include "ScnsSmctp.c.h"

#if defined(SCNS_SMCTP_ENABLE)&&SCNS_SMCTP_ENABLE==1

#include "ScnsMenu.h"
#include "ScnsMath.h"
#include "ScnsMath.h"

#include "main.h"
#include "usart.h"
#include "ScnsBeep.h"
#include "ScnsLed.h"

extern DMA_HandleTypeDef hdma_lpuart1_tx;

const ScnsSmctpChanelConfig scnsSmctpChanelConfig[SCNS_SMCTP_CHANNEL_MAX]={
    {.callback=scnsMenuReceiveInterrupt},/*SCNS_SMCTP_DEBUG*/
    {.callback=NULL},/*SCNS_SMCTP_VISUAL_SCOPE*/
};

ScnsStatus scnsBspSmctpCanSend(void)
{
    return SCNS_STATUS_OK;
}

int32 scnsBspSmctpSend(const uint8*buf,int32 len)
{
    if(HAL_OK!=HAL_UART_Transmit_DMA(&huart1,(uint8*)buf,len))
        scnsSmctpSendErrorCallback();
    return len;
}

void scnsBspSmctpSendErrorCallback(void)
{
}

void scnsBspSmctpReceiveIdleDmaStart(uint8*buf,uint32 len)
{
    if(HAL_OK!=HAL_UARTEx_ReceiveToIdle_DMA(&huart1,buf,len))
        scnsSmctpSendErrorCallback();
}

void scnsBspSmctpReceiveIdleDmaStop(uint8*buf,uint32 len)
{
    HAL_UART_AbortReceive(&huart1);
}

int32 scnsBspSmctpReceiveIdleDmaGetLength(void)
{
    return 0;
}

#endif